/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hiof.moraa.server.controller.restfulservice;

import com.hiof.moraa.server.service.LiveMediaService;
import com.hiof.moraa.server.service.model.Feed;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 *
 * @author manish
 */
@Controller
@RequestMapping("/restfulservice/liveMedia")
public class LiveMediaController {

    @Autowired
    LiveMediaService athleteLiveMediaService;
    @Autowired
    LiveMediaService supportLiveMediaService;

    @RequestMapping(value = "/athlete", method = RequestMethod.POST)
    @ResponseBody
    public Feed athleteLiveMediaServiceMethod(
            @RequestParam("userId") int userId,
            @RequestParam("athleteId") int athleteId,
            @RequestParam("file") MultipartFile file,
            @RequestParam("lat") double lat, @RequestParam("lng") double lng,
            @RequestParam("height") double height,
            HttpServletRequest request) throws Exception {
        return athleteLiveMediaService.processLiveMedia(userId, athleteId, file, lat, lng, height, request.getSession().getServletContext());
    }

    @RequestMapping(value = "/support", method = RequestMethod.POST)
    @ResponseBody
    public Feed supportLiveMediaServiceMethod(
            @RequestParam("userId") int userId,
            @RequestParam("supportId") int supportId,
            @RequestParam("file") MultipartFile file,
            @RequestParam("lat") double lat, @RequestParam("lng") double lng,
            @RequestParam("height") double height,
            HttpServletRequest request) throws Exception {
        return supportLiveMediaService.processLiveMedia(userId, supportId, file, lat, lng, height, request.getSession().getServletContext());
    }
}
